package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/8/22 11:20
 * @apiNote
 */

public class Test01232CheckStraightLine {

    public static void main(String[] args) {
        int[][] coordinates = new int[][]{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}};
        boolean flag = test(coordinates);
        System.out.println(flag);
    }

    public static boolean test(int[][] coordinates) {
        int deltaX = coordinates[0][0];
        int deltaY = coordinates[0][1];
        int n = coordinates.length;
        for (int i = 0; i < n; i++) {
            coordinates[i][0] -= deltaX;
            coordinates[i][1] -= deltaY;
        }
        //{{0,0},{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}
        int A = coordinates[1][1];
        int B = coordinates[1][0];
        for (int i = 2; i < n; i++) {
            int x = coordinates[i][0];
            int y = coordinates[i][1];
            if (x * A - y * B != 0) {
                return false;
            }
        }
        return true;
    }
}
